import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    name: 'layout',
    component: () => import('@/layout/index.vue'),
    redirect: '/popconfirm',
    children: [
      {
        path: '/popconfirm',
        name: 'popconfirm',
        meta: { title: 'table中放popconfirm' },
        redirect: '/popconfirm/singleTable',
        children: [
          {
            path: '/popconfirm/singleTable',
            name: 'singleTable',
            meta: { title: '一级table使用popconfirm' },
            component: () => import('@/views/popconfirm/SingleTable.vue'),
          },
          {
            path: '/popconfirm/multTable',
            name: 'multTable',
            meta: { title: '多级table使用popconfirm' },
            redirect: '/popconfirm/multTable/expandPop',
            children: [
              {
                path: '/popconfirm/multTable/expandPop',
                name: 'expandPop',
                meta: { title: '展开行中的表格使用popconfirm' },
                component: () => import('@/views/popconfirm/multTable/ExpandPop.vue'),
              },
              {
                path: '/popconfirm/multTable/treePop',
                name: 'treePop',
                meta: { title: '树形表格使用popconfirm' },
                component: () => import('@/views/popconfirm/multTable/TreePop.vue'),
              }
            ]
          }
        ]
      },
      {
        path: '/table',
        name: 'table',
        meta: { title: '表格' },
        redirect: 'table/expandPop',
        children: [
          {
            path: '/table/expandtable',
            name: 'expandtable',
            meta: { title: '展开行放表格' },
            component: () => import('@/views/table/ExpandTable.vue'),
          },
          {
            path: '/table/treetable',
            name: 'treetable',
            meta: { title: '树形表格' },
            component: () => import('@/views/table/TreeTable.vue'),
          },
          {
            path: '/table/mergerowtable',
            name: 'mergerowtable',
            meta: { title: '合并行' },
            component: () => import('@/views/table/MergerowTable.vue'),
          },
          {
            path: '/table/mergecoltable',
            name: 'mergecoltable',
            meta: { title: '合并列' },
            component: () => import('@/views/table/MergecolTable.vue'),
          },
          
          
        ]
      },
      {
        path: "/topu1",
        component: () => import("@/views/topu/topu1.vue"),
      },
    ]
  }
]

const router = createRouter({
  history: createWebHistory(process.env.BASE_URL),
  routes,
  scrollBehavior(to, from, savedPosition) {
    // 始终滚动到顶部
    return { top: 0 }
  },
})

export default router
